/************************************************************
 * Copyright (C), 2020-2030, Wondfo. Co., Ltd.
 * FileName:        log4qt_mgr.h
 * Author:			Dan Yin
 * Date:            2020-09-10
 * Description:		the class of log manage
 * Version:			1.0.0.0
 **********************************************************/

#ifndef LOG4QT_MGR_H
#define LOG4QT_MGR_H

#include <QtWidgets/QApplication>
#include <QDateTime>
#include <QDebug>

#define DF_LOG_CFG_FILE     "/conf/log4qt.cfg"
#define DF_CUR_TIME_EX      QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")

class Log4qtMgr : public QObject
{
    Q_OBJECT

public:
    // Get an instance of "Log4qtMgr" class, if exist, return it
    static Log4qtMgr* GetInstance();

    // Output data to the terminal
    void Output(QtMsgType mgsType, const QString & msgText);

    // Output data to the terminal
    void Output(QtMsgType mgsType, const QMessageLogContext & msgContext, const QString & msgText);

    // Get the error level info by error type number
    QString GetErrorLevelByType(int nErrType);

    // Get the error desc info by error code number
    QString GetErrorDescByCode(int nErrNum, bool bHex=false);

private:
    // The default constructor
    explicit Log4qtMgr();

    // The default destructor
    virtual ~Log4qtMgr();

    // After constructing object, initialize the object
    void _Initialze();

    // AES-128-CBC encryption
    QString EncryptionAES(const QString strSrc);

    // AES-128-CBC decrypt
    QString DecryptionAES(const QString strSrc);
};

#endif // LOG4QT_MGR_H
